using MySqlConnector;

namespace WinFormsApp1._1118;

public partial class Login : Form
{
    public Login()
    {
        InitializeComponent();
    }

   

    private void button1_Click_1(object sender, EventArgs e)
    {
        using var connection = new MySqlConnection("server=localhost;port=3306;database=book;user=root;password=200557;charset=utf8mb4;AllowPublicKeyRetrieval=True;");
        connection.Open();
        string sql = "SELECT *FROM admin_info where admian_account = @username and admian_password = @pwd";
        string username = this.textBox1.Text;
        string pwd = this.textBox2.Text;
        using var command = new MySqlCommand(sql, connection);
        using var reader = command.ExecuteReader();
        if (reader.HasRows)
        {
            MainForm mainForm = new MainForm();
            mainForm.Show();
            this.Hide();
        }
        else
        {
            MessageBox.Show("用户名或密码错误");
            textBox1.Show();
            textBox2.Show();
            
        }
    }

    private void textBox2_TextChanged(object sender, EventArgs e)
    {
        throw new System.NotImplementedException();
    }
}